﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="cadastro.aspx.cs" Inherits="BuyRitmus.Web.administracao.eventos.cadastro" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            Titulo   
            <asp:TextBox ID="TituloEvento" MaxLength="75" runat="server" />
            <br />
        
            Descricao
            <asp:TextBox ID="DescricaoEvento" MaxLength="1000" runat="server" TextMode="MultiLine" />
            <br />

            Data/Hora
            <asp:TextBox ID="DataEvento" MaxLength="10" runat="server" />
            <asp:TextBox ID="HoraEvento" MaxLength="5" runat="server" />
            <br />

            Estado
            <asp:DropDownList runat="server" ID="UfEvento"></asp:DropDownList>
            <br />

            Foto do Evento
            <asp:FileUpload ID="UploadFotoEvento" runat="server" />
            <br />

            <asp:Button ID="BtnGravarEvento" OnClientClick="validarUploadFoto()" ClientIDMode="Static" Text="Gravar" runat="server" OnClick="BtnGravarEvento_Click" />

        </div>
    </form>

    <script type="text/javascript" src="../../js/jquery-1.10.2.min.js"></script>
    <script type="text/javascript" src="../../js/jquery.maskedinput.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#DataEvento").mask("99/99/9999");
            $("#HoraEvento").mask("99:99");
        });

        function validarUploadFoto() {
            var validFilesTypes = ["bmp", "gif", "png", "jpg", "jpeg"];
            var file = document.getElementById("<%=UploadFotoEvento.ClientID%>");
            var path = file.value;
            var ext = path.substring(path.lastIndexOf(".") + 1, path.length).toLowerCase();
            var isValidFile = false;
            for (var i = 0; i < validFilesTypes.length; i++) {
                if (ext == validFilesTypes[i]) {
                    isValidFile = true;
                    break;
                }
            }
            if (!isValidFile) {
                alert("Extensão de arquivo inválido. Envie uma imagem válida com uma das seguintes extensões:\n" + validFilesTypes.join(", ") + ".");
            }
            return isValidFile;
        }
    </script>
</body>
</html>
